import request from '@/utils/request'

//抽取共同部分
const api_name='/admin/system/sysRole'
export default{
    

    getPageList(current,limit,searchObj){
        return request({
            url: `${api_name}/${current}/${limit}`,
            method: 'get',
            //普通对象参数传递写法，params:对象参数名称
            //JSON格式传递，data：对象参数名称
            params:searchObj
          })
    },
    //角色删除
    removeById(id){
        return request({
            url:`${api_name}/remove/${id}`,
            method:'delete'
        })
    },
    //角色添加
    saveRole(role){
        return request({
            url: `${api_name}/save`,
            method: 'post',
            //后端用requestBody接收，表示用JSON格式传递
            data: role
          })
    },
    //根据id查询，用于修改时的数据显示
    getById(id) {
        return request({
          url: `${api_name}/get/${id}`,
          method: 'get'
        })
      },
    //修改数据
    updateById(role) {
        return request({
          url: `${api_name}/update`,
          method: 'put',
          data: role
        })
    },
    //批量删除
    batchRemove(idList) {
        return request({
          url: `${api_name}/batchRemove`,
          method: `delete`,
          data: idList
        })
    },

    getRoles(adminId) {
      return request({
        url: `${api_name}/toAssign/${adminId}`,
        method: 'get'
      })
    },
    //给用户分配角色
    assignRoles(assginRoleVo) {
      return request({
        url: `${api_name}/doAssign`,
        method: 'post',
        data: assginRoleVo
      })
    }
}